import { BACKSTAGE } from "@/api/config/servicePort";
import http from "@/api";
import { Login, Result, Tenant } from "@/api/interface";
export default class xinweiBackstage {
  /** 获取字典数据 */
  getAllDictsList() {
    return http.get<any[]>(BACKSTAGE + `/system/dict-data/list-all-simple`);
  }
  /** 获取菜单列表 */
  getAuthMenuListApi = () => {
    return Promise.resolve({
      data: [
        {
          backStage: 2,
          name: "首页",
          enName: "Home",
          permission: "",
          type: 2,
          sort: 1,
          parentId: 0,
          path: "/home",
          routeName: "home",
          icon: "HomeFilled",
          component: "/home/index",
          status: 0,
          visible: true,
          keepAlive: true,
          redirectUrl: "",
          isLink: false,
          linkHref: "",
          isFull: false,
          activeMenu: "",
          id: 1456,
          createTime: 1687233067000,
          isAffix: true,
        },
        {
          id: 1482,
          backStage: 2,
          parentId: 0,
          name: "系统管理",
          enName: "System Manager",
          path: "/system",
          routeName: "system",
          component: null,
          icon: "UserFilled",
          visible: true,
          keepAlive: true,
          redirectUrl: "/system/menu",
          isLink: false,
          linkHref: "",
          isFull: false,
          activeMenu: "",
          children: [
            {
              id: 1484,
              backStage: 2,
              parentId: 1482,
              name: "菜单管理",
              enName: "Menu Manager",
              path: "/system/menu",
              routeName: "systemMenu",
              component: "/system/menu/index",
              icon: "Menu",
              visible: true,
              keepAlive: true,
              redirectUrl: "",
              isLink: false,
              linkHref: "",
              isFull: false,
              activeMenu: "",
              children: null,
            },
            {
              id: 1505,
              backStage: 2,
              parentId: 1482,
              name: "用户管理",
              enName: "account Manager",
              path: "/system/account",
              routeName: "systemAccount",
              component: "/system/account/index",
              icon: "User",
              visible: true,
              keepAlive: true,
              redirectUrl: "",
              isLink: false,
              linkHref: "",
              isFull: false,
              activeMenu: "",
              children: null,
            },
          ],
        },
      ],
    });

    return http.get<Menu.IMenu[]>(BACKSTAGE + `/system/auth/list-menus/2`, {}, { noLoading: true });
  };
  /** 获取按钮权限 */
  getAuthPermissionApi = () => {
    return http.get<Login.ResPermission>(BACKSTAGE + `/system/auth/get-permission-info/2`, {}, { noLoading: true });
    // 如果想让按钮权限变为本地数据，注释上一行代码，并引入本地 authButtonList.json 数据
    // return authButtonList;
  };
  /**  获取租户信息 */
  getTenantInfoApi = (id: string) => {
    return http.get<Tenant>(BACKSTAGE + `/system/tenant/get?id=${id}`);
  };
  /**修改用户头像 */
  updateUserAvatar = params => {
    return http.put<Result>(BACKSTAGE + "/system/user/profile/update-avatar", params, { params });
  };

  // 添加菜单
  addMenu = (params: Menu.MenuOptions) => {
    return http.post(BACKSTAGE + `/system/menu/create`, params);
  };
  // 修改菜单
  editMenu = (params: { id: string }) => {
    return http.put(BACKSTAGE + `/system/menu/update`, params);
  };

  deleteMenu = (params: { id: string }) => {
    return http.delete(BACKSTAGE + `/system/menu/delete`, params);
  };
  //获取菜单列表
  getMenuList = (params?: any) => {
    return http.get(BACKSTAGE + "/system/menu/list/2", params);
  };
}
